#include<stdio.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<string.h>

int main()
{   
    int fd = open("myfile.txt", O_RDONLY);
    if(fd < 0)
    {
      perror("open");
      return 1;
    }
    
    char buf[1024];
    while(1)
    {
      size_t s = read(fd, buf, 2);
      if(s > 0)
      {
        printf("%s", buf);
      }
      else{
        break;
      }
    }
    close(fd);
    return 0;
      //int fd = open("myfile.txt", O_WRONLY|O_CREAT, 0666);
    //if(fd < 0)
    //{
    //  perror("open");
    //  return 1;
    //}

    //printf("fd: %d\n", fd);
    //
    //const char* msg = "hello world\n";
    //int cnt = 1;
    //while(cnt)
    //{
    //  write(fd, msg, strlen(msg));
    //  cnt--;
    //}

    //close(fd);

  //return 0;
}
